Skip to content

Commit a4b139b

Browse files
committed
Docs: Incorrect casting instructions
1 parent ff51434 commit a4b139b

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ console.log('Squared Euclidean Distance:', distance);
448448
```
449449

450450
Other numeric types and precision levels are supported as well.
451-
For double-precsion floating-point numbers, use `Float64Array`:
451+
For double-precision floating-point numbers, use `Float64Array`:
452452

453453
```js
454454
const vectorA = new Float64Array([1.0, 2.0, 3.0]);
@@ -457,11 +457,11 @@ const distance = cosine(vectorA, vectorB);
457457
```
458458

459459
When doing machine learning and vector search with high-dimensional vectors you may want to quantize them to 8-bit integers.
460-
You may want to project values from the $[-1, 1]$ range to the $[-100, 100]$ range and then cast them to `Uint8Array`:
460+
You may want to project values from the $[-1, 1]$ range to the $[-127, 127]$ range and then cast them to `Int8Array`:
461461

462462
```js
463-
const quantizedVectorA = new Uint8Array(vectorA.map(v => (v * 100)));
464-
const quantizedVectorB = new Uint8Array(vectorB.map(v => (v * 100)));
463+
const quantizedVectorA = new Int8Array(vectorA.map(v => (v * 127)));
464+
const quantizedVectorB = new Int8Array(vectorB.map(v => (v * 127)));
465465
const distance = cosine(quantizedVectorA, quantizedVectorB);
466466
```
467467

javascript/simsimd.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,20 +83,20 @@ export const jaccard = (a: Uint8Array, b: Uint8Array): number => {
8383
};
8484

8585
/**
86-
* @brief Computes the kullbackleibler similarity coefficient between two vectors.
86+
* @brief Computes the Kullback-Leibler divergence between two vectors.
8787
* @param {Float64Array|Float32Array} a - The first vector.
8888
* @param {Float64Array|Float32Array} b - The second vector.
89-
* @returns {number} The Jaccard similarity coefficient between vectors a and b.
89+
* @returns {number} The Kullback-Leibler divergence between vectors a and b.
9090
*/
9191
export const kullbackleibler = (a: Float64Array | Float32Array, b: Float64Array | Float32Array): number => {
9292
return compiled.kullbackleibler(a, b);
9393
};
9494

9595
/**
96-
* @brief Computes the jensenshannon similarity coefficient between two vectors.
96+
* @brief Computes the Jensen-Shannon divergence between two vectors.
9797
* @param {Float64Array|Float32Array} a - The first vector.
9898
* @param {Float64Array|Float32Array} b - The second vector.
99-
* @returns {number} The Jaccard similarity coefficient between vectors a and b.
99+
* @returns {number} The Jensen-Shannon divergence between vectors a and b.
100100
*/
101101
export const jensenshannon = (a: Float64Array | Float32Array, b: Float64Array | Float32Array): number => {
102102
return compiled.jensenshannon(a, b);

0 commit comments

Comments
 (0)