-
Notifications
You must be signed in to change notification settings - Fork 140
Expand file tree
/
Copy pathEmbedderDistribution.java
More file actions
56 lines (51 loc) · 1.85 KB
/
EmbedderDistribution.java
File metadata and controls
56 lines (51 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package com.meilisearch.sdk.model;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
/**
* Describes the natural distribution of search results for embedders. Contains mean and sigma
* values, each between 0 and 1.
*/
@Builder
@AllArgsConstructor(access = AccessLevel.PACKAGE)
@NoArgsConstructor(access = AccessLevel.PUBLIC)
@Getter
@Setter
@Accessors(chain = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class EmbedderDistribution {
/** Mean value of the distribution, between 0 and 1 */
private Double mean;
/** Sigma (standard deviation) value of the distribution, between 0 and 1 */
private Double sigma;
/**
* Creates a uniform distribution with default values
*
* @return An EmbedderDistribution instance with mean=0.5 and sigma=0.5
*/
public static EmbedderDistribution uniform() {
return new EmbedderDistribution().setMean(0.5).setSigma(0.5);
}
/**
* Creates a custom distribution with specified mean and sigma values
*
* @param mean Mean value between 0 and 1
* @param sigma Sigma value between 0 and 1
* @return An EmbedderDistribution instance with the specified values
* @throws IllegalArgumentException if mean or sigma are outside the valid range
*/
public static EmbedderDistribution custom(double mean, double sigma) {
if (mean < 0 || mean > 1) {
throw new IllegalArgumentException("Mean must be between 0 and 1");
}
if (sigma < 0 || sigma > 1) {
throw new IllegalArgumentException("Sigma must be between 0 and 1");
}
return new EmbedderDistribution().setMean(mean).setSigma(sigma);
}
}